<?php

$star = 1;
if ($_GET['id']) {
    $id = $_GET['id'];
}
require_once('../libraryfiles/config.php');

if ($_GET['confirm']) {
    $confirm = $_GET['confirm'];
}

/* check user */
$where_user = array(
    Tbluser::activate => $confirm,
    Tbluser::email => $id,
);
$string = select(Tbluser::Tbluser, array(Tbluser::activate, Tbluser::id), $where_user);
/* check user by Socheat Ngann */
if (dbNumRows($string)) {
    /* activate user */
    $SET = array(
        Tbluser::status => 1
    );
    $where_update = array(
        Tbluser::activate => $confirm,
        Tbluser::email => $id,
    );
    $update_user = update(Tbluser::Tbluser, $SET, $where_update);
    if($update_user) {
        header('Location:../login.php?success=USER_ACTIVATED');
        exit();
    } else {
        header('Location:../login.php?error=USER_CANNOT_ACTIVATE');
    }
    /* end activate user */
} else {
    header('Location:../login.php?error=USER_NOT_EXIST');
}